Word Export

Hi,
I was trying to write a DXL Script to open a word document and type a string in the document.
Attached is the script.

The script is able to open a brand new word document, but it is not able to get the text printed over there..
Can someone help me in getting to the solution.

When i tried to debug, it shows up the message as "Problem with OLE Argument names."
Thanks
Matthew
Lion29 - Fri Jul 15 19:50:28 EDT 2011

Re: Word Export
Mathias Mamsch - Sat Jul 16 09:23:20 EDT 2011

Maybe you should take a close look at the Word Object Model. Also it can help, to try doing stuff like this in VBA before switching to DXL, since in VBA you can experiment much better with the properties of the word objects, you got stuff like autocompletion in the editor, which will immediately tell you what properties exist on an object. To use the 'type...' methods you need a Selection object which is a property of the Word.Application object. Therefore the code needs to look like this:
 

//Assign the variables
//--------------------------------Include Files------------------------------------------------------------
#include <utils/ole.inc>
#include <utils/doctools/itfutil.inc>
 
Object o = current
Module m = current
string g = "Object Text"
 
void TryOLE(string s, string info)
{
    if(s == null) return
        print info "\n"
        print s "\n"
}
 
OleAutoObj theWordApp = null
OleAutoObj objWordDocs = null, objDoc = null
OleAutoObj objSelection = null
OleAutoArgs autoArgs = create
bool docVisible
 
// create the app
theWordApp = oleCreateAutoObject("Word.Application")
 
// don't care if it is already visible ...
olePut (theWordApp, "visible", true)
 
// Get ActiveDocument.Selection
TryOLE(oleGet(theWordApp,cPropertyDocuments,objWordDocs), "Getting Documents")
TryOLE(oleMethod(objWordDocs, cMethodAdd, autoArgs, objDoc), "Adding Document")
oleCloseAutoObject objWordDocs // nicely clean up .
 
TryOLE(oleGet(theWordApp, "Selection", objSelection), "Getting Selection")
 
clear autoArgs
put(autoArgs, "adjahksdjhd")
 
TryOLE(oleMethod(objSelection, "TypeText", autoArgs), "Typin ...")
TryOLE(oleMethod(objSelection, "TypeParagraph"), "Doin a paragraph")
 
clear autoArgs
put(autoArgs, "And a new one ...")
TryOLE(oleMethod(objSelection, "TypeText", autoArgs), "Typin some more")

 


Hope that helps, regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Word Export
Lion29 - Mon Jul 18 18:07:25 EDT 2011

Mathias Mamsch - Sat Jul 16 09:23:20 EDT 2011

Maybe you should take a close look at the Word Object Model. Also it can help, to try doing stuff like this in VBA before switching to DXL, since in VBA you can experiment much better with the properties of the word objects, you got stuff like autocompletion in the editor, which will immediately tell you what properties exist on an object. To use the 'type...' methods you need a Selection object which is a property of the Word.Application object. Therefore the code needs to look like this:
 

//Assign the variables
//--------------------------------Include Files------------------------------------------------------------
#include <utils/ole.inc>
#include <utils/doctools/itfutil.inc>
 
Object o = current
Module m = current
string g = "Object Text"
 
void TryOLE(string s, string info)
{
    if(s == null) return
        print info "\n"
        print s "\n"
}
 
OleAutoObj theWordApp = null
OleAutoObj objWordDocs = null, objDoc = null
OleAutoObj objSelection = null
OleAutoArgs autoArgs = create
bool docVisible
 
// create the app
theWordApp = oleCreateAutoObject("Word.Application")
 
// don't care if it is already visible ...
olePut (theWordApp, "visible", true)
 
// Get ActiveDocument.Selection
TryOLE(oleGet(theWordApp,cPropertyDocuments,objWordDocs), "Getting Documents")
TryOLE(oleMethod(objWordDocs, cMethodAdd, autoArgs, objDoc), "Adding Document")
oleCloseAutoObject objWordDocs // nicely clean up .
 
TryOLE(oleGet(theWordApp, "Selection", objSelection), "Getting Selection")
 
clear autoArgs
put(autoArgs, "adjahksdjhd")
 
TryOLE(oleMethod(objSelection, "TypeText", autoArgs), "Typin ...")
TryOLE(oleMethod(objSelection, "TypeParagraph"), "Doin a paragraph")
 
clear autoArgs
put(autoArgs, "And a new one ...")
TryOLE(oleMethod(objSelection, "TypeText", autoArgs), "Typin some more")

 


Hope that helps, regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Thanks a lot..
Got it working..

Re: Word Export
Lion29 - Thu Jul 21 20:11:27 EDT 2011

Lion29 - Mon Jul 18 18:07:25 EDT 2011
Thanks a lot..
Got it working..

Is there anyway to handle the OLE Objects from the Object text to the word document. I tried to copy, but there were some cases where there is multiple OLE's embedded into a single object. and some texts also inbetween the OLE's of the same object...

Re: Word Export
Mathias Mamsch - Fri Jul 22 04:06:09 EDT 2011

Lion29 - Thu Jul 21 20:11:27 EDT 2011
Is there anyway to handle the OLE Objects from the Object text to the word document. I tried to copy, but there were some cases where there is multiple OLE's embedded into a single object. and some texts also inbetween the OLE's of the same object...

You probably need to loop over the richTextParagraphs pasting them one by one.

RichTextParagraph rp
for rp in richText obj."Object Text" do {
    // export them one by one ...
}

 


Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS